package geppetto.phraseHMM.phraseExtraction.phraseAccepter;

import java.util.ArrayList;

import geppetto.main.adaptation.AdaptationInfo;
import geppetto.phraseHMM.phraseExtraction.extractedphrase.ExtractedPhrasePair;

public class AdaptedSpecificTypeAccepter  extends AbstractPhraseAccepter{
	AdaptationInfo adaptationInfo;
	ArrayList<String> acceptedTypes;
	
	public AdaptedSpecificTypeAccepter(AdaptationInfo adaptationInfo, ArrayList<String> acceptedTypes) {
		this.adaptationInfo = adaptationInfo;
		this.acceptedTypes = acceptedTypes;
	}	

	/*public  boolean acceptPhrase(int sentenceNumber, byte sentenceSource, int[] foreingSentence, int[] sourceSentence, int sourceStartPos, int sourceEndPos,int foreignStartPos, int foreignEndPos, double score){
		String[] types = adaptationInfo.getSentenceTokenTypes(sentenceNumber);
		for(int i = sourceStartPos; i <= sourceEndPos; i++){
			if(!acceptedTypes.contains(types[i])){
				return false;
			}
		}
		return true;
	}
*/
	@Override
	public boolean acceptPhrase(ExtractedPhrasePair epp) {
		int sentenceNumber = epp.getSentenceNumber();
		int sourceStartPos = epp.getSourceStartPos();
		int sourceEndPos = epp.getSourceEndPos();
		String[] types = adaptationInfo.getSentenceTokenTypes(sentenceNumber);
		for(int i = sourceStartPos; i <= sourceEndPos; i++){
			if(!acceptedTypes.contains(types[i])){
				return false;
			}
		}
		return true;
	}
	
}
